/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pi.dao;

import br.com.pi.pojo.Fornecedor;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author Aluno
 */
public class FornecedorDAOImp extends BaseDAOImp<Fornecedor, Long> implements FornecedorDAO{

    @Override
    public Fornecedor pesquisarPorId(Long id) throws Exception {
        session = FabricaSessao.abreSessao().openSession();
        Fornecedor fornecedor = (Fornecedor) session.get(Fornecedor.class, id);
        session.close();
        return fornecedor;
    }

    @Override
    public List<Fornecedor> getTodos() throws Exception {
        session = FabricaSessao.abreSessao().openSession();
        Query query = session.createQuery("from Fornecedor");
        List<Fornecedor> fornecedores = query.list();        
        session.close();
        return fornecedores;
    }
    
}
